<template>
	<view class="" :style="{ paddingTop: heig + 'px' }">
		<view class="">
			<navBar name=" " img="/static/topBg.png" :bgShow="true" :bgheiht="710"></navBar>
		</view>
		<view class="topAva f f-a-c f-j-b">
			<view @click="goUserinfo" class="lef f f-a-c">
				<image :src="userinfo.avatar" class="avatImg" mode="aspectFill"></image>
				<view class="nameRi">{{userinfo.nickname}}</view>
				<image src="/static/richang/icon@2x.png" v-if="userinfo.gender==2" class="icon" mode=""></image>
				<image src="/static/richang/icon_1@2x.png" v-else class="icon" mode=""></image>
			</view>
			<view class="rig">
				<image src="/static/my/MECATS@2x.png" class="imgs" mode=""></image>
				<view @click.stop="goUseinFo" class="boxBtn f f-a-c f-j-c">
					主页 <image src="/static/my/Frame@.png" class="jiantou" mode=""></image>
				</view>
			</view>
		</view>
		<view class="follow f f-a-c">
			<view @click="attenion" class="item f f-j-c f-a-c f-d-c">
				<view class="num">{{obj.follows}}</view>
				<view class="name">关注</view>
			</view>
			<view @click="myFans" class="item f f-j-c f-a-c f-d-c">
				<view class="num">{{obj.fans}}</view>
				<view class="name">粉丝</view>
			</view>
			<view @click="maomaoClick" class="item f f-j-c f-a-c f-d-c">
				<view class="num">{{obj.pets}}</view>
				<view class="name">猫猫</view>
			</view>
		</view>
		<view class="bor  b-r-25 b-f f f-a-c f-j-b">
			<view @click="MallOrder" class="items f f-a-c f-j-c f-d-c">
				<view class="num">{{total}}</view>
				<image src="/static/my/icon_my_01@2x.png" class="isocn" mode=""></image>
				<view class="order">商城订单</view>
			</view>
			<view @click="MyThum" class="items f f-a-c f-j-c f-d-c">
				<image src="/static/my/icon_my_02@2x.png" class="isocn" mode=""></image>
				<view class="order">我的收藏</view>
			</view>
			<view @click="myZan" class="items f f-a-c f-j-c f-d-c">
				<image src="/static/my/icon_my_03@2x.png" class="isocn" mode=""></image>
				<view class="order">我的点赞</view>
			</view>
			<view @click="myInteg" class="items f f-a-c f-j-c f-d-c">
				<image src="/static/my/icon_my_04@2x.png" class="isocn" mode=""></image>
				<view class="order">我的积分</view>
			</view>
		</view>
		<view class="bor b-r-25 b-f">
			<view @click="goMyCoupon" class="topItem f f-a-c f-j-b">
				<view class="lef f f-a-c">
					<image src="/static/my/icon_01@2x.png" class="rollImg" mode=""></image>
					<view class="myRoll">我的优惠卷</view>
				</view>
				<image src="/static/my/youjian.png" class="youjiantou" mode=""></image>
			</view>
			<view @click="goAddress" class="topItem f f-a-c f-j-b">
				<view class="lef f f-a-c">
					<image src="/static/my/icon_02@2x.png" class="rollImg" mode=""></image>
					<view class="myRoll">收货地址</view>
				</view>
				<image src="/static/my/youjian.png" class="youjiantou" mode=""></image>
			</view>
			<view @click="show=true" class="topItem f f-a-c f-j-b">
				<view class="lef f f-a-c">
					<image src="/static/my/icon_03@2x.png" class="rollImg" mode=""></image>
					<view class="myRoll">我要推荐</view>
				</view>
				<image src="/static/my/youjian.png" class="youjiantou" mode=""></image>
			</view>
			<button style="padding: 0;margin: 0;border: none;" open-type="contact" :plain="true">
				<view class="topItem topItems f f-a-c f-j-b">
					<view class="lef f f-a-c">
						<image src="/static/my/icon_04@2x.png" class="rollImg" mode=""></image>
						<view class="myRoll">平台客服</view>
					</view>
					<image src="/static/my/youjian.png" class="youjiantou" mode=""></image>
				</view>
			</button>
		</view>
		<!-- 下面的加群 -->
		<view @click="AdditionGroup" class="jiaqun">
			<image src="/static/my/bg.png" class="imgIc" mode=""></image>
		</view>
		<tabBar numBer="4"></tabBar>
		<!-- 遮罩层 -->
		<u-mask :show="show">
			<view class="center b-f">
				<image :src="codeImg" class="erCode" mode=""></image>
				<image src="/static/my/cha.png" @click="show = false" class="chaImg" mode=""></image>
				<image src="/static/my/bgBg.png" class="bgBg" mode=""></image>
				<view class="btn f f-a-c f-j-c">
					<view @click="shareToWeChat" class="weCode">保存二维码</view>
					<view @click="shareToWeChat" class="weCath">转发微信好友</view>
				</view>
			</view>
		</u-mask>
	</view>
</template>

<script>
	import navBar from '@/components/navBar.vue';
	export default {
		components: {
			navBar
		},
		data() {
			return {
				heig: '',
				show: false,
				userinfo: uni.getStorageSync('userInfo'),
				obj: {},
				total: 0,
				imgUrl: '',
				codeImg: ''
			}
		},
		onShow() {
			this.userinfo = uni.getStorageSync('userInfo')
			this.heig = uni.getStorageSync('ht');
			this.userInfoHome()
			this.orderList()
			this.initCode()
		},
		methods: {
			// 点击保存
			shareToWeChat() {
				wx.downloadFile({
					url: this.codeImg,
					success: (res) => {
						wx.showShareImageMenu({
							path: res.tempFilePath,
							success: res => {
								this.$msg('保存成功')
							},
							fail: red => {
								this.$msg('保存失败')
							}
						})

					}
				})
			},
			async initCode() {
				let n = await this.$api.getCode({
					scene: `code=${this.userinfo.id}`
				})
				this.codeImg = n.data.data
			},
			// /订单列表
			async orderList() {
				let n = await this.$api.orderList({
					page: 1,
					status: 3
				})
				this.total = n.data.total
			},
			// 个人主页信息
			async userInfoHome() {
				let n = await this.$api.userInfo()
				this.obj = n.data
			},
			// 去我的猫猫
			maomaoClick() {
				uni.navigateTo({
					url: '/pages/home/Management'
				})
			},
			// 去加群
			AdditionGroup() {
				uni.navigateTo({
					url: '/pages/my/AdditionGroup'
				})
			},
			// 去商城订单
			MallOrder() {
				uni.navigateTo({
					url: '/pageB/MallOrder'
				})
			},
			// 去我的优惠卷
			goMyCoupon() {
				uni.navigateTo({
					url: '/pageB/MyCoupon'
				})
			},
			// 去我的粉丝
			myFans() {
				uni.navigateTo({
					url: '/pageB/MyFans'
				})
			},
			// /去关注
			attenion() {
				uni.navigateTo({
					url: '/pageB/MyAttention'
				})
			},
			// 去个人主页
			goUseinFo() {
				uni.navigateTo({
					url: '/pageB/PersonalHomepage?id=' + this.userinfo.id
				})
			},
			// /去个人资料
			goUserinfo() {
				uni.navigateTo({
					url: '/pageB/Userinfo'
				})
			},
			// 我的点赞 我的收藏
			myZan() {
				uni.navigateTo({
					url: '/pageB/MyThumbsUp'
				})
			},
			// 我的收藏 我的收藏 我的积分
			MyThum() {
				uni.navigateTo({
					url: '/pageB/MyCollection'
				})
			},
			//  我的积分
			myInteg() {
				uni.navigateTo({
					url: '/pageB/MyIntegral'
				})
			},
			goAddress() {
				uni.navigateTo({
					url: '/pages/shoop/ReceivingAddress'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.center {
		position: relative;
		margin-top: 40%;
		width: 75%;
		height: 800rpx;
		margin-left: 50%;
		transform: translateX(-50%);
		border-radius: 30rpx;

		.erCode {
			position: absolute;
			top: 30rpx;
			left: 30rpx;
			width: 160rpx;
			height: 160rpx;
			z-index: 111;
		}

		.chaImg {
			position: absolute;
			bottom: -110rpx;
			left: 50%;
			transform: translateX(-50%);
			width: 74rpx;
			height: 74rpx;
		}

		.btn {
			margin-top: 15rpx;

			.weCath {
				width: 240rpx;
				height: 70rpx;
				line-height: 70rpx;
				background: #977961;
				border-radius: 44rpx;
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-500;
				font-weight: 500;
				text-align: center;
				color: #fffefc;
				margin-left: 20rpx;
			}

			.weCode {
				width: 240rpx;
				height: 70rpx;
				line-height: 70rpx;
				background: #fffefc;
				border: 2rpx solid #977961;
				border-radius: 46rpx;
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-500;
				font-weight: 500;
				text-align: center;
				color: #977961;
			}
		}

		.bgBg {
			width: 100%;
			border-radius: 30rpx 30rpx 0 0;
			height: 680rpx;
		}
	}

	.jiaqun {
		width: 90%;
		margin: 0 auto;
		height: 184rpx;
		border-radius: 24rpx;
		overflow: hidden;
		margin-top: 25rpx;

		.imgIc {
			width: 100%;
			height: 100%;
		}
	}

	.topItem {
		margin-bottom: 50rpx;

		.youjiantou {
			width: 16rpx;
			height: 24rpx;
		}

		.lef {
			.rollImg {
				width: 40rpx;
				height: 40rpx;
			}

			.myRoll {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-500;
				font-weight: 600;
				text-align: LEFT;
				color: #2f2319;
				margin-left: 25rpx;
			}
		}
	}

	.topItems {
		margin-bottom: 0;
	}

	.bor {
		width: 90%;
		margin: 0 auto;
		margin-top: 30rpx;
		padding: 40rpx 30rpx;

		.items {
			position: relative;

			.isocn {
				width: 74rpx;
				height: 72rpx;
			}

			.order {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-400;
				font-weight: 400;
				text-align: center;
				color: #2f2319;
				margin-top: 10rpx;
			}

			.num {
				position: absolute;
				right: -10rpx;
				top: -10rpx;
				width: 36rpx;
				height: 36rpx;
				line-height: 35rpx;
				background: #977961;
				border: 2rpx solid #ffffff;
				border-radius: 20rpx;
				text-align: center;
				font-size: 20rpx;
				font-family: PingFang SC, PingFang SC-500;
				font-weight: 500;
				color: #fffefc;
			}
		}
	}

	.follow {
		padding: 0 40rpx;
		margin-top: 10rpx;
		justify-content: space-around;

		.item {

			.num {
				font-size: 36rpx;
				font-family: HarmonyOS Sans, HarmonyOS Sans-700;
				font-weight: 700;
				text-align: LEFT;
				color: #2f2319;
			}

			.name {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-400;
				font-weight: 400;
				text-align: LEFT;
				color: #ada6a0;
				margin-top: 5rpx;
			}
		}
	}

	.topAva {
		height: 168rpx;
		padding: 0 40rpx;

		.rig {
			.imgs {
				width: 112rpx;
				height: 24rpx;
			}

			.boxBtn {
				width: 112rpx;
				height: 52rpx;
				border: 2rpx solid #2f2319;
				border-radius: 28rpx;
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-500;
				font-weight: 600;
				text-align: LEFT;
				color: #2f2319;
				margin-top: 5rpx;

				.jiantou {
					width: 8rpx;
					height: 16rpx;
					margin-left: 10rpx;
				}
			}
		}

		.lef {
			.avatImg {
				width: 120rpx;
				height: 120rpx;
				border-radius: 60rpx;
				margin-right: 25rpx;
			}

			.icon {
				width: 28rpx;
				height: 28rpx;
				margin-left: 20rpx;
			}

			.nameRi {
				font-size: 40rpx;
				font-family: PingFang SC, PingFang SC-600;
				font-weight: 600;
				text-align: LEFT;
				color: #2f2319;
			}
		}
	}
</style>